﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace datatool
{
    public class DataWord : INotifyPropertyChanged
    {
        private string _value;
        public int Address { get; set; }

        public string Value
        {
            get => _value;
            set
            {
                if (System.Text.RegularExpressions.Regex.IsMatch(value, @"^[0-9A-Fa-f]{0,4}$"))
                {
                    _value = value.ToUpper();
                    OnPropertyChanged();
                }
            }
        }


        private string commMsg;

        public string CommMsg
        {
            get { return commMsg; }
            set { commMsg = value; OnPropertyChanged(); }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged([CallerMemberName] string name = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
    }

}
